//
//  ChatCustomDecoder.m
//  BGM
//
//  Created by 我要变好看 on 2018/12/26.
//  Copyright © 2018 com.alirtc.demo. All rights reserved.
//

#import "ChatCustomDecoder.h"
#import "ChatCustom.h"

@implementation ChatCustomDecoder

//NSDictionary *dict = @{@"title":self.title,@"subTitle":self.subTitle,@"iconType":self.iconType};

-(id<NIMCustomAttachment>)decodeAttachment:(NSString *)content{
    id<NIMCustomAttachment> attachment;
    NSData *data = [content dataUsingEncoding:NSUTF8StringEncoding];
    if (data) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
        NSDictionary *dataObject = [dict objectForKey:@"data"];
        if ([dataObject isKindOfClass:[NSDictionary class]]) {
            NSString *messageId = [dataObject objectForKey:@"messageId"];
            NSString *helpUsersId = [dataObject objectForKey:@"helpUsersId"];
            NSString *connectionUserId = [dataObject objectForKey:@"connectionUserId"];
            
            NSString *pushType = [dataObject objectForKey:@"pushType"];
            NSString *pushTxt = [dataObject objectForKey:@"pushTxt"];
            NSString *pushTitle = [dataObject objectForKey:@"pushTitle"];

//            NSString *messageJson = [dataObject objectForKey:@"dic"];
            ChatCustom *custom = [[ChatCustom alloc]init];
            custom.messageId = messageId;
            custom.helpUsersId = helpUsersId;
            custom.connectionUserId = connectionUserId;
            custom.pushType =pushType;
            custom.pushTxt = pushTxt;
            custom.pushTitle = pushTitle;
//            custom.dic = messageJson;
            attachment = custom;
        }
       
 
     }
    return attachment;
}

@end
